package com.example.XueCuApp.Customer;

import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;


import com.example.XueCuApp.Bean.JJHCheckResultOtherBean;
import com.example.XueCuApp.R;
import com.example.XueCuApp.Utils.DialogDesign;

public class SecondConfigDialog {

    private static SecondConfigDialog secondConfigDialog;
    private DialogClickListener dialogClickListener;
    private DialogDesign dialog = null;
    private JJHCheckResultOtherBean ResultBean;

    public void setDialogClickListener(DialogClickListener dialogClickListener) {
        this.dialogClickListener = dialogClickListener;
    }

    public static SecondConfigDialog getInstance() {
        if (secondConfigDialog == null) {
            synchronized (SecondConfigDialog.class) {
                if (secondConfigDialog == null) {
                    secondConfigDialog = new SecondConfigDialog();
                }
            }
        }
        return secondConfigDialog;
    }

    public void showDialog(Activity activity, JJHCheckResultOtherBean ResultBean) {
        View view = LayoutInflater.from(activity).inflate(R.layout.meassagenotice_dialogs, null);
        TextView ok = view.findViewById(R.id.btn_ok);
        TextView quxiao = view.findViewById(R.id.quxiao);
        TextView ticketName = view.findViewById(R.id.tv_second_config_ticket_name);
        TextView ticketNumber = view.findViewById(R.id.tv_second_config_people_number);
        TextView ticketPeopleName = view.findViewById(R.id.tv_second_config_type_name);
        TextView ticketType = view.findViewById(R.id.tv_second_config_type);
        TextView ticketTypeNumber = view.findViewById(R.id.tv_second_config_type_number);

        if (ResultBean.getData() != null) {
            ticketName.setText(ResultBean.getData().getTicketName());
            ticketNumber.setText(ResultBean.getData().getPassPersonSum());
            ticketPeopleName.setText(ResultBean.getData().getCertificateName());
            ticketType.setText(ResultBean.getData().getCertificateTypeName());
            ticketTypeNumber.setText(ResultBean.getData().getCertificateNo());
        }

        ok.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dialogClickListener.ok();
                dialog.cancel();
            }
        });

        //  取消进入详情
        quxiao.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                // 取消 就是查看详情， 查看详情回调 要带参数过去吧，
                dialogClickListener.quxiao();
                dialog.cancel();
            }
        });

        dialog = new DialogDesign(activity, 0, 0, view, R.style.DialogTheme);
        if (!dialog.isShowing() && !activity.isFinishing()) {
            dialog.show();
        }

    }

    public interface DialogClickListener {

        void ok();

        void quxiao();
    }
}
